export default {
      getGuid() {
            var guid = '';
            for (var i = 1; i <= 32; i++) {
                  var n = Math.floor(Math.random() * 16.0).toString(16);
                  guid += n;
                  if (i == 8 || i == 12 || i == 16 || i == 20) {
                        guid += '-';
                  }
            }
            return guid;
      },
      getYestDayDateString() {
            var today = new Date().valueOf();
            today = today + -1 * 24 * 60 * 60 * 1000;
            today = new Date(today);
            var year = today.getFullYear();
            var month = (today.getMonth() + 1).toString().length === 2 ? (today.getMonth() + 1) : '0' + (today.getMonth() + 1);
            var day = today.getDate().toString().length === 2 ? today.getDate() : '0' + today.getDate();
            var timeStr = year + '' + month + '' + day;
            return timeStr + '~' + timeStr;
      },
      getYestDay() {
            return new Date((new Date().getTime()) - (24 * 60 * 60 * 1000));
      },
      //字符串转日期----字符串日期：20200214
      string2Date(s) {
            if (s) {
                  var str = s.toString();
                  var strDate = str.substr(0, 4) + '/' + str.substr(4, 2) + '/' + str.substr(6, 2);
                  return new Date(strDate);
            }
            return new Date();
      },
      date2String(date) {
            var today = date;
            var year = today.getFullYear();
            var month = (today.getMonth() + 1).toString().length === 2 ? (today.getMonth() + 1) : '0' + (today.getMonth() + 1);
            var day = today.getDate().toString().length === 2 ? today.getDate() : '0' + today.getDate();
            return year + '' + month + '' + day;
      },
      //数字增加千位分隔符
      toThousands(num) {
            return num.toString().replace(/\d+/, function (n) { // 先提取整数部分
                  return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) { // 对整数部分添加分隔符
                        return $1 + ',';
                  });
            });
      },
      //copy表格
      copyTable(strID) {
            var text = document.getElementById(strID);
            var range;
            if (document.createRange() && window.getSelection) {
                  var selection = window.getSelection();
                  selection.removeAllRanges();
                  range = document.createRange();
                  range.selectNodeContents(text);
                  selection.addRange(range);
                  document.execCommand('copy');
                  selection.removeAllRanges();
            } else if (document.body.createTextRange) {
                  //createTextRange是用在IE中的
                  range = document.body.createTextRange();
                  range.moveToElementText(text);
            }else{
                  return null;
            }
            global.msg_instance.showMsgNew({
                  title: 'COMMON_030'
            });
      }
};